<template>
  <div class="ccui-app-container">
    <div class="pageCenter">
      <div class="appActivationLogin" v-if="step === 1">
        <p class="title">激活{{ $store.state.user.userDetal.agentName }}应用</p>
        <p class="apmsg">
          感谢您第一个使用{{
            $store.state.user.userDetal.agentName
          }}应用，您可点击下一步申请成为应用的管理员并完成应用激活。
        </p>
      </div>
      <div class="appActivationMode" v-if="step === 2">
        <p class="title">新建审批流程</p>
        <p class="apmsg">
          为本单位各类审批业务审批流程创建审批流程，并全部初始化为自审批，如需自定义流程审批环节和审批人，可联系单位流程管理员配置审批流程
        </p>
        <div v-for="(item, index) in saveAppConfig" :key="index">
          <p class="apmsg1">{{ item.name }}（审批业务编码：{{ item.code }}）</p>
          <el-checkbox
            v-for="itemChildren in item.subList"
            :label="itemChildren"
            :key="itemChildren.name"
            :checked="checked"
            disabled
            >{{ itemChildren.name }} （审批类型编码：{{
              itemChildren.code
            }}）</el-checkbox
          >
        </div>
      </div>
      <div class="appActivationWelcom" v-if="step === 3">
        <div class="imgbox">
          <img :src="imgUrl" />
        </div>
        <p class="jscg">激活成功</p>
        <p class="jsapp">
          您已被指定为{{ $store.state.user.userDetal.agentName }}应用的管理员
        </p>
      </div>
      <div class="btnBottom">
        <el-button
          type="primary"
          class="wdi"
          v-if="step === 1"
          @click="oneNext('ruleForm')"
          >下一步</el-button
        >
        <div class="btnBox" v-if="step === 2">
          <el-button type="primary" class="vv" @click="step -= 1"
            >上一步</el-button
          >
          <el-button type="primary" class="vv" @click="oneNext"
            >下一步</el-button
          >
        </div>
        <el-button type="primary" class="wdi" v-if="step === 3" @click="oneNext"
          >开始使用</el-button
        >
      </div>
    </div>
  </div>
</template>

<script>
// import validators from "@/basa/utils/validators";
import { getCheckList, saveInfo } from "../api/appactivation";
// checkLogin, saveInfo,getCheckList
export default {
  data() {
    return {
      step: 1,
      radioClass: 1,
      imgUrl: require("@/basa/assets/images/scee.png"),
      checked: true,
      saveAppConfig: [],
      saveAppConfigList: []
    };
  },
  methods: {
    oneNext(ruleForm) {
      let obj;
      if (this.step === 1) {
        this.step += 1;
        getCheckList({}).then(res => {
          if (res.data.code === "0") {
            this.saveAppConfig = res.data.data;
            this.saveAppConfig.forEach(item => {
              item.subList.forEach(items => {
                this.saveAppConfigList.push({
                  configName: "初始化审批流程",
                  configCode: `${item.name}-${items.name}`,
                  configVlaue: `${item.code}-${items.code}`
                });
              });
            });
          }
        });
      } else if (this.step === 2) {
        console.log(this.saveAppConfigList);
        const baseAppId = "100011";
        obj = {
          saveAppConfigList: this.saveAppConfigList,
          appId: baseAppId
        };
        saveInfo(obj).then(res => {
          if (res.data.code === "0") {
            this.step += 1;
          }
        });
      } else if (this.step === 3) {
        window.location.reload();
      }
    }
  }
};
</script>

<style lang="scss" scoped>
/*@import "~@/styles/variables";*/
.appActivationBoxT {
  width: 100%;
  height: 100%;
}
.appActivationBoxO {
  width: 100%;
  min-height: 973px;
}
.pageCenter {
  padding-bottom: 60px;
  /*position: absolute;
    left: 50%;
    width: 500px;
    min-height: calc(100vh - 195px);
    margin-left: -250px;*/
}
.appActivationLogin,
.appActivationMode,
.appActivationWelcom {
  margin: 0 auto;
  width: 500px;
}
/*.btnBottomO {*/
/*  position: absolute;*/
/*  bottom: 0;*/
/*}*/
/*.btnBottomT {*/
/*  position: absolute;*/
/*}*/
.btnBottom {
  position: absolute;
  bottom: 20px;
  left: 50%;
  margin-left: -250px;
}
.wdi {
  width: 500px;
}
.vv {
  width: 240px;
}
.vv:nth-child(even) {
  float: right;
}
.vv:nth-child(odd) {
  float: left;
}
.apmsg {
  font-size: 14px;
  color: #4a4a4a;
  line-height: 24px;
  margin-bottom: 20px;
}
.title {
  font-size: 24px;
  color: #4a4a4a;
  line-height: 33px;
  // margin-bottom: 10px;
  // margin-top: 35px;
  padding: 35px 0px 10px 0px;
}
/*ul li {
    display: block;
    margin-bottom: 10px;
  }*/
/*.credit-title {
    margin: 50px 0px 10px 0px;
    height: 33px;
    font-size: 24px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #4a4a4a;
    line-height: 33px;
  }*/
/*.credit-text {
    height: 18px;
    font-size: 13px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #4a4a4a;
    line-height: 18px;
    margin-bottom: 20px;
  }*/
/*.credit-quota {
    height: 18px;
    font-size: 13px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #4a4a4a;
    line-height: 18px;
    margin-bottom: 10px;
  }*/
/deep/ .el-button--primary {
  height: 40px;
  line-height: 40px;
}
/deep/ .el-button--primary span {
  font-size: 16px;
}
/deep/ .el-input__inner {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}
/deep/ .el-input__inner {
  height: 40px;
}
.diyLabel {
  display: inline-block;
  vertical-align: top;
  width: 68px;
  height: 38px;
  border: 1px solid #cccccc;
  font-size: 13px;
  color: #4a4a4a;
  text-align: center;
  line-height: 38px;
  border-right: 0;
  border-top-left-radius: 2px;
  border-bottom-left-radius: 2px;
}
.jscg {
  font-size: 30px;
  color: #4a4a4a;
  line-height: 42px;
  margin: 20px 0;
  text-align: center;
}
.jsapp {
  font-size: 20px;
  color: #4a4a4a;
  line-height: 28px;
  text-align: center;
}
.imgbox {
  width: 60px;
  height: 60px;
  margin-top: 145px;
  margin-left: 220px;
}
.imgbox img {
  width: 100%;
}
.apmsgBox {
  margin-bottom: 20px;
}
.apmsg1 {
  margin-bottom: 10px;
}
/deep/.el-checkbox {
  display: block;
  margin-bottom: 10px;
}
/deep/.el-checkbox__input.is-disabled.is-checked {
  .el-checkbox__inner {
    background-color: #0089ef;
    border-color: #0089ef;
  }
  .el-checkbox__inner::after {
    border-color: #ffffff;
  }
  .el-checkbox__label {
    color: #4a4a4a !important;
  }
}
/deep/.el-checkbox__input.is-disabled + span.el-checkbox__label {
  color: #4a4a4a !important;
}
</style>
